package operation;

import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    public void work(BookList bookList){
        System.out.println("查找图书");
        System.out.println("请输入你要查找的图书名字：");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.next();
        int curSize=bookList.getUsedSize();
        int i = 0;
        for (; i < curSize; i++) {
            if(bookList.getBooks(i).getName().equals(name)){
                System.out.println(bookList.getBooks(i));
                return;
        }
    }
        if(i==curSize)
            System.out.println("无此书，将自动返回最初页面");
        work(bookList);
    }
}
